package com.tianquan;


import org.mybatis.spring.annotation.MapperScan;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@MapperScan("com.tianquan.mapper")
@EnableScheduling
public class UploaddemoApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(UploaddemoApplication.class, args);
        // ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        //
        // SqlSessionFactory sqlSessionFactory = beanFactory.getBean(SqlSessionFactory.class);
        // Configuration configuration = sqlSessionFactory.getConfiguration();
        // System.out.println(configuration);
        // SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE);
        // DefaultMapResultHandler resultHandler = new DefaultMapResultHandler("id", new DefaultObjectFactory(),
        //         new DefaultObjectWrapperFactory(), new DefaultReflectorFactory());
        // sqlSession.select("com.tianquan.mapper.DishMapper.getById", 46L, resultHandler);
        // System.out.println("=============================");
        // resultHandler.getMappedResults().forEach((o, o2) -> System.out.println(o + " " + o2));

        // DishMapper dishMapper = beanFactory.getBean(DishMapper.class);
        // System.out.println(dishMapper.getById(46L));
        //
        // dishMapper.getById(46L);


        // springSPI
        // UserService userService = context.getBean(UserService.class);
        // System.out.println(userService.getName());

    }

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://127.0.0.1:6379");
        return Redisson.create(config);
    }

}
